Component({
    properties: {},
    data: {
        tab: {
            active: 0,
            list: [
                {
                    name: '首页',
                    icon: 'home',
                    url: '/pages/home/index',
                    isDevice: false
                },
                {
                    name: '社区',
                    icon: 'device',
                    url: '/community/pages/home/index',
                    isDevice: false
                },
                {
                    name: '商城',
                    icon: 'shop',
                    url: '/shop/pages/home/index',
                    isDevice: false
                },
                {
                    name: '我的',
                    icon: 'my',
                    url: '/mine/pages/home/index',
                    isDevice: false
                }
            ]
        },
    },
    lifetimes: {
        attached() {
        },
        detached() {
        },
    },
    methods: {
        stopScroll(){return},
        handlerTab(e) {
            const {index, item} = e.currentTarget.dataset
            if (item.url) {
                this.hiddenModal()
                wx.navigateTo({url: item.url})
                return
            } 
            this.data.tab.active = index
            this.data.tab.list.map((item, idx) => {
                if (idx == index) {
                    if (index == 1) {
                        item.isDevice = !item.isDevice
                    } else {
                        // item.isDevice = true
                        // this.data.tab.list[1].isDevice = false
                    }
                    return
                }
            })
            this.setData({
                tab: this.data.tab
            })
        },
        hiddenModal() {
            this.setData({
                'tab.list[1].isDevice': false
            })
        }
    }
})
